package com.pifuke.patient.ui;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import cn.o.app.adapter.OAdapter;
import cn.o.app.adapter.OItemView;
import cn.o.app.ui.OImageView;
import cn.o.app.util.OUtil;

import com.evan.common.pullrefresh.PullToRefreshListView;
import com.pifuke.patient.R;
import com.smiier.skin.net.entity.UserWrapper;
import com.smiier.skin.ui.BasicFragment;
import com.umeng.analytics.MobclickAgent;

public class PatientOfDoctorFragment extends BasicFragment {

	protected PullToRefreshListView mListView;

	protected PatientOfDoctorAdapter mAdapter;

	public PatientOfDoctorFragment(Context context) {
		super(context);
	}

	public PatientOfDoctorFragment(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public PatientOfDoctorFragment(Context context, AttributeSet attrs,
			int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public void onCreate() {
		super.onCreate();
		setContentView(R.layout.fragment_patient_of_doctor);

		mListView = this.findViewById(R.id.list, PullToRefreshListView.class);
		mAdapter = new PatientOfDoctorAdapter();
		mListView.setAdapter(mAdapter);

		List<PatientOfDoctorItem> dataItems = new ArrayList<PatientOfDoctorFragment.PatientOfDoctorItem>();
		for (int i = 0; i < 10; i++) {
			PatientOfDoctorItem item = new PatientOfDoctorItem();
			dataItems.add(item);
		}
		mAdapter.setDataProvider(dataItems);
	}

	protected static boolean isSameClass(Date d, Date another) {
		return false;
	}

	class PatientOfDoctorItem {
		public Boolean mIsFirst4Class;
		public Boolean mIsLast4Class;
		public Integer mCount4Class;
		protected UserWrapper mUserData;
	}

	class PatientOfDoctorAdapter extends OAdapter<PatientOfDoctorItem> {

		@Override
		public OItemView<PatientOfDoctorItem> getItemView() {
			return new PatientOfDoctorItemView(getContext());
		}

	}

	class PatientOfDoctorItemView extends OItemView<PatientOfDoctorItem> {
		protected TextView mTime;
		protected TextView mCount;
		protected View mTopLine;
		protected View mBottomLine;
		protected OImageView mLogo;
		protected TextView mName;
		protected TextView mProfile;
		protected TextView mSourceFrom;

		protected float mBottomMarginLeft;

		public PatientOfDoctorItemView(Context context) {
			super(context);
		}

		@Override
		public void onCreate() {
			this.setContentView(R.layout.item_patient_of_doctor);
			mTime = this.findViewById(R.id.time, TextView.class);
			mCount = this.findViewById(R.id.count, TextView.class);
			mTopLine = this.findViewById(R.id.top_line, View.class);
			mBottomLine = this.findViewById(R.id.bottom_line, View.class);
			mLogo = this.findViewById(R.id.logo, OImageView.class);
			mName = this.findViewById(R.id.name, TextView.class);
			mProfile = this.findViewById(R.id.profile, TextView.class);
			mSourceFrom = this.findViewById(R.id.source_from, TextView.class);

			mBottomMarginLeft = OUtil.dp2px(getContext(), 16);
		}

		@Override
		public void onResume() {
			if (mDataProvider.mIsFirst4Class == null) {
				doInit4Class();
			}
		}

		protected void doInit4Class() {

		}
	}
	
	
/*	@Override
	public void onResume() {
		super.onResume();
		MobclickAgent.onResume(getContext());
	}

	@Override
	public void onPause() {
		super.onPause();
		MobclickAgent.onPause(getContext());
	}*/
}
